<template>
   <div>
       <table>
           <tr>
               <td>id</td>
               <td>书名</td>
               <td>详情</td>
           </tr>
           <tr v-for="i in books_list">
               <td>{{i.id}}</td>
               <td>{{i.name}}</td>
               <td><van-button @click="indexs(i.name)">点击</van-button></td>
           </tr>
       </table>
   </div>
</template>

<script>
export default {
   data () {
      return {
        aid:this.$route.query.aid,
        books_list:[]
      };
   },

   methods: {
       //跳转详情信息
       indexs:function(aname){
           var a = localStorage.getItem(aname)
           if (a){
               a++
               localStorage.setItem(aname,a)
           }else{
               localStorage.setItem(aname,1)
           }
       },
        //获取所有书籍
       get_books:function(){
           this.axios.get(this.localhost+'books/?aid='+this.aid)
           .then(res=>{
               console.log(res.data);
               this.books_list = res.data;
           })
       },
   },

   computed: {},

   mounted() {
       this.get_books();
   },

   components: {}
}
</script>
<style lang='css' scoped>

</style>